﻿using System;
using System.Collections.Generic;
using System.Text;
using yiracli;

namespace yirabot
{
    class Program
    {
        static void Main (string [] args)
        {
            Console.WriteLine("yirabot 0.1");

            string usr = args[0];
            string pwd = args[1];

            // auto..
            Autorizacion yiraAuto = new Autorizacion(usr, pwd);

            // usr...
            User yiraUser = User.get (yiraAuto, usr);
            Console.WriteLine("Bienvenido {0}!", yiraUser.displayName);

            // issues...
            List<Issue> issues = Issue.get (yiraAuto, usr);
            Console.WriteLine("Issues:");
            issues.Sort(new Comparison<Issue>(comparadorIssue));
            foreach (Issue issueX in issues)
            {
                if (issueX.status == "Cerrado")
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                else
                    Console.ForegroundColor = ConsoleColor.Cyan;

                Console.WriteLine(" -> {0} {1} {2} {3}", issueX.key, issueX.summary, issueX.status, issueX.priority);

                //Console.WriteLine(WorkLog.get(yiraAuto, issueX));
            }
            
            Console.ReadLine();
        }

        static int comparadorIssue (Issue issue1, Issue issue2)
        {
            return issue1.key.CompareTo(issue2.key);
        }
    }
}
